/**
 * 用户管理管理初始化
 */
var HhtbusersInvited = {
    id: "HhtbusersInvitedTable",	//表格id
    seItem: null,		//选中的条目
    table: null,
    layerIndex: -1
};

/**
 * 初始化表格的列
 */
HhtbusersInvited.initColumn = function () {
    return [
        {field: 'selectItem', radio: true},
            {title: '序号', field: 'userId', visible: true, align: 'center', valign: 'middle',
                formatter: function (value, row, index) {
                    return index+1;
                }
            },
            {title: '手机号', field: 'userPhone', visible: true, align: 'center', valign: 'middle'},
            {title: '用户名', field: 'userName', visible: true, align: 'center', valign: 'middle'},
            {title: '用户类型', field: 'userType', visible: true, align: 'center', valign: 'middle',formatter:HhtbusersInvited.userType},
            {title: '账号状态', field: 'userStatus', visible: false, align: 'center', valign: 'middle',formatter:HhtbusersInvited.userStatus},
            {title: '创建时间', field: 'createTime', visible: false, align: 'center', valign: 'middle'},
            {title: '真实姓名', field: 'trueName', visible: true, align: 'center', valign: 'middle'},
    ];
};
//用户类型
HhtbusersInvited.userType = function(value){
    var result = '';
    if(value == 0){
        result = '初始用户';
    }else if(value == 2000){
        result = '普通用户';
    }else if(value == 5000){
        result = '主管';
    }else if(value == 10000){
        result = '经理';
    }
    return result;
}
//账号状态
HhtbusersInvited.userStatus= function(value){
    var result = '';
    if(value == 0){
        result = '停用';
    }else if(value == 1){
        result = '启用';
    }
    return result;
}
//是否允许转换
HhtbusersInvited.isOperation= function(value){
    var result = '';
    if(value == 0){
        result = '不允许';
    }else if(value == 1){
        result = '允许';
    }
    return result;
}

/**
 * 查询用户管理列表
 */
HhtbusersInvited.search = function () {
    var queryData = {};
    queryData['userPhone'] = $("#userPhone").val();
    queryData['userName'] = $("#userName").val();
    HhtbusersInvited.table.refresh({query: queryData});
};

$(function () {
    debugger
    var userId = $("#userId").val();
    var defaultColunms = HhtbusersInvited.initColumn();
    var table = new BSTable(HhtbusersInvited.id, "/hhtbusers/selectInvitedList?userId="+userId, defaultColunms);
    table.setPaginationType("server");
    HhtbusersInvited.table = table.init();
});
